home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGNG_C / TCXL21.LZH / TCXL.DOC next >
Text File  |  1988-01-25  |  54KB  |  1,849 lines

  1.                                    TCXL.LIB
  2.                     An Extended Functions Library for Turbo C
  3.                                   Version 2.1
  4.                                  by Mike Smedley
  5.                        (c) 1987, 1988  All Rights Reserved
  6.  
  7.     This library is intended to be a supplement to the Turbo C function
  8. library.  It was written to be used with the tiny and small memory models.
  9. Several of the functions were written in assembly language without any calls to
  10. the Turbo C function library.  This makes it possible for assembly language
  11. programmers to call these functions even if they don't have Turbo C.  The
  12. functions in this library are very compact and fast.  The following files
  13. should be included in this archive:
  14.  
  15.                 TCXL.DOC      - the library documentation
  16.                 TCXL.H        - the header file
  17.                 TCXL.HST      - history of changes
  18.                 TCXL.LIB      - the object code library
  19.                 TCXLDEMO.C    - the demonstration program source code
  20.                 TCXLDEMO.COM  - the demonstration program
  21.                 TCXLDEMO.MAK  - the make file used for compiling the demo
  22.                 TCXLDEMO.PRJ  - project file used for compiling the demo
  23.  
  24.     You are free to copy and distribute this library freely, however, if you
  25. find this library of use to you, you are encouraged to register your copy.  The
  26. registration cost is $20.  Included in this registration cost is technical
  27. support, a free upgrade to the next major revision, and best of all the
  28. complete library source code!  Also included in the registration cost are the
  29. shipping and handling costs.  This library may not be used in commercial
  30. applications without registration.  To register, please send payment to:
  31.  
  32.                     Mike Smedley
  33.                     2441 N.E. Loop 410
  34.                     San Antonio, TX 78217
  35.  
  36. Or for more information, call (512) 590-2910, no collect calls please.
  37.  
  38. DISCLAIMER:  The author claims no responsibility for any damages caused by the
  39. use or misuse of this library.  This product is distributed "as is" with no
  40. warranty expressed or implied.
  41.  
  42. Turbo C is a registered trademark of Borland International.
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.                                       1
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.                           Calling Functions from Turbo C
  69.                           ------------------------------
  70.  
  71.     To call these functions from Turbo C, you will need to have a line in your
  72. source code file including the TCXL header file:  #include "tcxl.h".  To find
  73. out what the syntax is of the functions, refer to this documentation or look
  74. at the TCXL.H file.  You will also need to link in the TCXL.LIB file when you
  75. link your program.  You can do this one of three ways:
  76.  
  77.         1.  environment compile:  put 'TCXL.LIB' in your .PRJ file
  78.         2.  command line compile:  tcc myfile tcxl.lib
  79.         3.  command line link:  tlink c0s myfile,myfile,,tcxl cs /c/x
  80.  
  81.  
  82.  
  83.                      Calling Functions from Assembly Language
  84.                      ----------------------------------------
  85.  
  86.     Turbo C passes its arguments to a function via the stack.  Arguments are
  87. pushed onto the stack in reverse order.  Turbo C places the underscore symbol
  88. preceeding the function name, so to call the getsf function you must call it by
  89. _getsf.  After the call to the function, you must readjust the stack.  For
  90. every push on the stack, the stack pointer needs to be incremented by 2.  The
  91. return value (if any) will be in the AX register.  Functions that return type
  92. long will have the high value in DX and the low value in AX.  The functions
  93. that can be called by assembly language are listing in the next section with a
  94. plus sign(+) preceeding their name.  Here's an example for the getsf()
  95. function:
  96.  
  97.             EXTRN   _getsf:NEAR         ; so assembler won't flag an error
  98.             mov     ax,27               ; maximum length of input string
  99.             push    ax                  ; push it onto the stack
  100.             mov     ax,OFFSET name      ; address of string to receive input
  101.             push    ax                  ; push it onto the stack
  102.             call    _getsf              ; call the function
  103.             add     sp,4                ; adjust stack 2 for every argument
  104.             or      ax,ax               ; is return a 0?  (Esc not pressed)
  105.             jnz     exitprog            ; no, Esc was pressed, exit program
  106.             (rest of program)
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.                                       2
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.                               Overview of Functions
  135.                               ---------------------
  136.  
  137.   attrib    - creates an attribute
  138. + beep      - sounds a beep in the speaker
  139. + biosver   - returns the BIOS version date
  140. + box       - draws a box on the screen
  141. + boxd      - draws a box directly on the screen (no BIOS calls)
  142.   capsoff   - toggles the <Caps Lock> key off
  143.   capson    - toggles the <Caps Lock> key on
  144.   clearkeys - clears the keyboard buffer
  145. + clockcal  - determines if a clock-calendar board is installed
  146. + clreol_   - clears to the end of line
  147. + clrscrn   - clears the screen and homes the cursor
  148.   clrwin    - clears a window of the screen
  149.   cls       - clears the screen and homes the cursor
  150. + delay_    - delays program execution
  151. + extmem    - determines the amount of extended memory on an AT machine
  152.   fcmpdatm  - compares 2 file's dates and times
  153.   fhide     - hides a disk file
  154. + fill      - fills in a region of the screen
  155. + filld     - fills in a region of the screen (no BIOS calls)
  156.   gameport  - determines if a game port is installed
  157. + getchf    - gets a key from the keyboard from a valid list of characters
  158. + getktot   - gets the total disk space in kilobytes
  159. + getsf     - inputs a string from the keyboard, limiting length
  160.   getvol    - gets the volume label from a disk drive
  161. + gotoxy_   - plots cursor coordinates on the screen
  162.   home      - homes the cursor
  163.   kbstat    - returns the keyboard status
  164.   lcrlf     - prints a carriage return and line feed on the printer
  165. + lprintc   - prints a character on the printer
  166. + lprints   - prints a string on the printer
  167. + lprintsf  - prints a string on the printer, formatting width
  168. + machid    - returns the value of the machine ROM ID byte
  169.   mathchip  - determines if a math coprocessor is installed
  170. + mode      - sets the video mode
  171.   numflop   - returns the number of floppy disk drives installed
  172.   numoff    - toggles the <Num Lock> key off
  173.   numon     - toggles the <Num Lock> key on
  174.   numpar    - returns the number of parallel ports installed
  175.   numser    - returns the number of serial ports installed
  176. + printc    - displays a character on the screen at location & attribute
  177. + printcd   - displays a character directly on screen at location & attribute
  178. + prints    - displays a string on the screen at location & attribute
  179. + printsd   - displays a string directly on the screen at location & attribute
  180.   prompts   - prompts for a string and accepts keyboard input
  181. + readchat  - reads the character and attribute under the cursor
  182. + readcur   - reads the current cursor location
  183. + revattr   - reverses the attribute of char under the current cursor location
  184. + scrndump  - dumps the current CGA screen to the printer
  185. + setattr   - sets the attribute of the character under current cursor location
  186. + setcursz  - sets the cursor size
  187. + sound_    - sounds a tone in the speaker for specified pitch and duration
  188. + spc       - displays specified number of spaces to the screen
  189.   srestore  - restores a previously saved CGA screen
  190.  
  191.  
  192.                                       3
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.   ssave     - saves the current CGA screen
  200. + strchg    - changes all matching characters in a string to another
  201. + strdel    - deletes a substring from within a string
  202. + strichg   - changes all matching chars in a string to another, ignoring case
  203. + stridel   - deletes a substring from within a string, ignore case of letters
  204. + striinc   - determines if one string is included in another, ignoring case
  205. + strinc    - determines if one string is included in another
  206. + striocc   - returns num of occurrences of char within a string, ignore case
  207.   strleft   - returns a substring from the left of a string
  208.   strmid    - returns a substring from the middle of a string
  209. + strocc    - returns the number of occurrences of a character within a string
  210.   strright  - returns a substring from the right of a string
  211.   strsetsz  - sets a string to a specified size, truncating or concatenating
  212. + tabstop   - calculates a tab stop from given column and tab width
  213. + timer     - returns the value of the BIOS timer
  214. + vidtype   - returns the video display adapter type
  215.   wactiv    - activates an open window
  216.   waitkey   - halts execution until a key is pressed
  217.   wclear    - clears the active window
  218.   wclose    - closes the active window
  219.   wclreol   - clears to the end of the active window's line
  220.   wgetc     - gets a character from the keyboard within active window
  221.   wgetchf   - gets a character from keyboard within window, controlling input
  222.   wgets     - gets a string from the keyboard within active window
  223.   wgetsf    - gets a string from keyboard within active window, limiting length
  224.   wgotoxy   - plots cursor coordinates within active window
  225.   whide     - hides a window
  226.   wmove     - moves an active window to a new location
  227.   wopen     - opens and activates a window on a CGA screen
  228.   wprintc   - prints a character in the active window
  229.   wprints   - prints a string in the active window
  230.   wputc     - prints a character in the active window at curr cursor location
  231.   wputs     - prints a string in the active window at current cursor location
  232.   wputsf    - prints a string in the active window formatting length
  233.   wrestore  - restores a previously saved window of CGA screen memory
  234.   wsave     - saves a window of CGA screen memory
  235.   wscroll   - scrolls the text in the active window, up or down
  236.   wsize     - adjusts the size of the active window
  237.   wtextattr - sets the default text attribute used by some windowing functions
  238.   wunhide   - reveals a hidden window
  239.  
  240.  
  241. +  independent of the Turbo C functions library and preprocessor
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.                                       4
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.                                Detail of Functions
  267.                                -------------------
  268.  
  269.  
  270. Name:       attrib
  271. Purpose:    creates an attribute
  272. Prototype:  int attrib(int fore,int back,int bright,int blink)
  273. Inputs:     fore    - foreground color code (0-7)
  274.             back    - background color code (0-7)
  275.             bright  - intensity (0-1)
  276.             blink   - blinking (0-1)
  277. Return:     attribute
  278. Also see:   box boxd fill filld printc printcd prints printsd wopen
  279. Example:
  280.             prints(15,10,attrib(7,5,1,0),"Hello, world");
  281.  
  282.  
  283. Name:       beep
  284. Purpose:    sounds a beep in the speaker
  285. Prototype:  void beep(void)
  286. Inputs:     none
  287. Return:     none
  288. Also see:   sound_
  289. Example:
  290.             beep();
  291.  
  292.  
  293. Name:       biosver
  294. Purpose:    returns the ROM BIOS version date
  295. Prototype:  char *biosver(void)
  296. Inputs:     none
  297. Return:     address of the static string containing the ROM BIOS version date
  298. Also see:   machid
  299. Example:
  300.             char *romver;
  301.             romver=biosver();
  302.             printf("ROM BIOS version date is %s\n",romver);
  303.  
  304.  
  305. Name:       box
  306. Purpose:    draws a box on the screen
  307. Prototype:  void box(int srow,int scol,int erow,int ecol,int btype,int atr)
  308. Inputs:     srow    - starting row upper left corner
  309.             scol    - starting column upper left corner
  310.             erow    - ending row lower right corner
  311.             ecol    - ending column
  312.             btype   - box type (0-3)
  313.             atr     - attribute
  314. Return:     none
  315. Also see:   attrib boxd fill filld wopen
  316. Example:
  317.             box(0,0,22,79,1,WHITE|_BLUE);
  318.  
  319.  
  320. Name:       boxd
  321. Purpose:    draws a box directly on the screen (no BIOS calls)
  322.  
  323.  
  324.                                       5
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331. Prototype:  void boxd(int srow,int scol,int erow,int ecol,int btype,int atr)
  332. Inputs:     srow    - starting row upper left corner
  333.             scol    - starting column upper left corner
  334.             erow    - ending row lower right corner
  335.             ecol    - ending column
  336.             btype   - box type (0-3)
  337.             atr     - attribute
  338. Return:     none
  339. Also see:   attrib box fill filld wopen
  340. Example:
  341.             boxd(0,0,22,79,1,WHITE|_BLUE);
  342.  
  343.  
  344. Name:       capsoff
  345. Purpose:    toggles the <CapsLock> key off
  346. Prototype:  void capsoff(void)
  347. Inputs:     none
  348. Return:     none
  349. Also see:   capson kbstat numoff numon
  350. Example:
  351.             capsoff();
  352.  
  353.  
  354. Name:       capson
  355. Purpose:    toggles the <CapsLock> key on
  356. Prototype:  void capson(void)
  357. Inputs:     none
  358. Return:     none
  359. Also see:   capsoff kbstat numoff numon
  360. Example:
  361.             capson();
  362.  
  363.  
  364. Name:       clearkeys
  365. Purpose:    clears the keyboard buffer
  366. Prototype:  void clearkeys(void)
  367. Inputs:     none
  368. Return:     none
  369. Also see:   waitkey
  370. Example:
  371.             int ch;
  372.             printf("Press a key:  ");
  373.             clearkeys();
  374.             ch=getche();
  375.  
  376.  
  377. Name:       clockcal
  378. Purpose:    determines if a clock-calendar board is installed (usually this
  379.             board will only be in XT machines)
  380. Prototype:  int clockcal(void)
  381. Inputs:     none
  382. Return:     a non-zero value if a clock-calendar board is present
  383. Also see:   gameport mathchip numflop numpar numser
  384. Example:
  385.             printf("A clock-calendar is%s installed\n",clockcal()?"":" not");
  386.  
  387.  
  388.  
  389.  
  390.                                       6
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397. Name:       clreol_
  398. Purpose:    clears to the end of line
  399. Prototype:  void clreol_(void)
  400. Inputs:     none
  401. Return:     none
  402. Also see:   clrscrn clrwin
  403. Example:
  404.             prints(10,5,LCYAN|_BLUE,"Hello, worldXXXXXXXX");
  405.             gotoxy_(10,17);
  406.             clreol_();
  407.  
  408.  
  409. Name:       clrscrn
  410. Purpose:    clears the screen and homes the cursor
  411. Prototype:  void clrscrn(void)
  412. Inputs:     none
  413. Return:     none
  414. Also see:   clreol_ clrwin
  415. Example:
  416.             clrscrn();
  417.  
  418.  
  419. Name:       clrwin
  420. Purpose:    clears a window of the screen
  421. Prototype:  void clrwin(srow,scol,erow,ecol)
  422. Inputs:     srow    - starting row upper left corner
  423.             scol    - starting column upper left corner
  424.             erow    - ending row lower right corner
  425.             ecol    - ending column lower right corner
  426. Return:     none
  427. Also see:   clreol_ clrscrn
  428. Example:
  429.             filld(10,10,20,20,'X',LCYAN|_BLUE);
  430.             clrwin(11,11,19,19);
  431.  
  432.  
  433. Name:       cls
  434. Purpose:    clears the screen and homes the cursor
  435. Prototype:  void cls(void)
  436. Inputs:     none
  437. Return:     none
  438. Also see:   clreol_ clrwin
  439. Example:
  440.             cls();
  441.  
  442.  
  443. Name:       delay_
  444. Purpose:    delays program execution for a specified duration
  445. Prototype:  void delay_(unsigned duration)
  446. Inputs:     duration    - duration (0-65535) ie. 18 = 1 second
  447. Return:     none
  448. Also see:   timer
  449. Example:
  450.             printf("Testing\n1\n");
  451.             delay_(36);
  452.             printf("2\n");
  453.             delay_(36);
  454.  
  455.  
  456.                                       7
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.             printf("3\n");
  464.  
  465.  
  466. Name:       extmem
  467. Purpose:    determines the amount of extended memory on an AT machine
  468. Prototype:  unsigned extmem(void)
  469. Inputs:     none
  470. Return:     the amount of extended memory in Kilobytes
  471. Example:
  472.             printf("Amt of extended memory = %dK\n",extmem());
  473.  
  474.  
  475. Name:       fcmpdatm
  476. Purpose:    compares the dates and times of 2 files
  477. Prototype:  int fcmpdatm(char *fname1,char *fname2)
  478. Inputs:     fname1  - address of string containing filename1
  479.             fname2  - address of string containing filename2
  480. Return:     -1 if less than or equal to, 0 if error, 1 if greater than
  481. Example:
  482.             int i;
  483.             i=fcmpdatm("C:FILE1.EXT","A:FILE1.EXT");
  484.             if(i>0) printf("Backup copy of file needs refreshing\n");
  485.  
  486.  
  487. Name:       fhide
  488. Purpose:    hides a disk file
  489. Prototype:  int fhide(char *filename)
  490. Inputs:     filename    - address of string containing file name
  491. Return:     a zero if an error occurred
  492. Example:
  493.             if(!fhide("MYFILE.EXT")) {
  494.                 printf("Could not hide file\n");
  495.                 exit(1);
  496.             }
  497.  
  498.  
  499. Name:       fill
  500. Purpose:    fills in a region of the screen with specified character/attribute
  501. Prototype:  void fill(int srow,int scol,int erow,int ecol,int ch,int atr)
  502. Inputs:     srow    - starting row upper left corner
  503.             scol    - starting column upper left corner
  504.             erow    - ending row lower left corner
  505.             ecol    - ending column lower left corner
  506.             ch      - character to fill with
  507.             atr     - attribute of character
  508. Return:     none
  509. Also see:   attrib box boxd filld wopen
  510. Example:
  511.             box(1,1,10,10,3,LMAGENTA|_CYAN);
  512.             fill(2,2,9,9,' ',WHITE|_RED);
  513.  
  514.  
  515. Name:       filld
  516. Purpose:    fills in a region of the screen with specified character/attribute
  517.             by writing directly to the screen (no BIOS calls)
  518. Prototype:  void filld(int srow,int scol,int erow,int ecol,int ch,int atr)
  519. Inputs:     srow    - starting row upper left corner
  520.  
  521.  
  522.                                       8
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.             scol    - starting column upper left corner
  530.             erow    - ending row lower left corner
  531.             ecol    - ending column lower left corner
  532.             ch      - character to fill with
  533.             atr     - attribute of character
  534. Return:     none
  535. Also see:   attrib box boxd fill wopen
  536. Example:
  537.             boxd(1,1,10,10,3,LMAGENTA|_CYAN);
  538.             filld(2,2,9,9,' ',WHITE|_RED);
  539.  
  540.  
  541. Name:       gameport
  542. Purpose:    determines if a game port is installed
  543. Prototype:  int gameport(int equip)
  544. Inputs:     equip   - the result from the biosequip() function
  545. Return:     a 1 if a game port is installed
  546. Also see:   clockcal mathchip numflop numpar numser
  547. Example:
  548.             int i;
  549.             i=biosequip();
  550.             printf("Game port is %sinstalled\n",gameport(i)?"":"not ");
  551.  
  552.  
  553. Name:       getchf
  554. Purpose:    gets a character from the keyboard from a list of valid
  555.             characters
  556. Prototype:  int getchf(char *valid)
  557. Inputs:     valid   - address of list of valid characters
  558. Return:     the character pressed or the Escape (ASCII 27) if it was pressed
  559. Also see:   getsf
  560. Example:
  561.             char ch;
  562.             printf("Are you sure?  ");
  563.             ch=getchf("YyNn");
  564.             if(ch!='Y'&&ch!='y') {
  565.                 exit(0);
  566.             }
  567.  
  568.  
  569. Name:       getktot
  570. Purpose:    gets the total disk space in kilobytes
  571. Prototype:  unsigned getktot(int drive)
  572. Inputs:     drive   - the drive to check (3 = C:, 4 = D:, etc.)
  573. Return:     size of the specified disk in kilobytes, -1 if error
  574. Example:
  575.             printf("drive C: contains %u kilobytes\n",getktot(3));
  576.  
  577.  
  578. Name:       getsf
  579. Purpose:    inputs a string of specified length from the keyboard, checking
  580.             for the Escape key being pressed
  581. Prototype:  int getsf(char *str,int max)
  582. Inputs:     str     - address of location to receive input string
  583.             max     - maximum length of the input string
  584. Return:     a 1 if the <Esc> key was pressed
  585. Also see:   getchf
  586.  
  587.  
  588.                                       9
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595. Example:
  596.             char age[2];
  597.             printf("Enter your age:  ");
  598.             if(getsf(age,2)) {
  599.                 printf("Escape was pressed\n");
  600.                 exit(0);
  601.             }
  602.  
  603.  
  604. Name:       getvol
  605. Purpose:    gets the volume label from a disk drive
  606. Prototype:  char *getvol(char drive)
  607. Inputs:     drive   - drive letter
  608. Return:     address of a static string containing the volume label or a zero if
  609.             the disk has no volume label
  610. Example:
  611.             printf("The volume label on drive C is:  %s\n",getvol('C'));
  612.  
  613.  
  614. Name:       gotoxy_
  615. Purpose:    set cursor coordinates on the screen
  616. Prototype:  void gotoxy_(int row,int col)
  617. Inputs:     row     - cursor row
  618.             col     - cursor column
  619. Return:     none
  620. Also see:   printc printcd prints printsd readcur
  621. Example:
  622.             gotoxy_(20,30);
  623.             printf("We are at row 20, column 30\n");
  624.  
  625.  
  626. Name:       home
  627. Purpose:    homes the cursor
  628. Prototype:  void home(void)
  629. Inputs:     none
  630. Return:     none
  631. Also see:   clrscrn gotoxy_
  632. Example:
  633.             home();
  634.             printf("We are at row 0, column 0\n");
  635.  
  636.  
  637. Name:       kbstat
  638. Purpose:    determines the status of the keyboard control keys
  639. Prototype:  int kbstat(void)
  640. Inputs:     none
  641. Return:     status word of the keyboard flag
  642. Also see:   capsoff capson numoff numon
  643. Example:
  644.             if(kbstat()&CTRL) printf("The <Ctrl> key is now being pressed\n");
  645.  
  646.  
  647. Name:       lcrlf
  648. Purpose:    prints a carriage return and line feed on the printer
  649. Prototype:  void lcrlf(void)
  650. Inputs:     none
  651. Return:     none
  652.  
  653.  
  654.                                       10
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661. Also see:   lprintc lprints lprintsf
  662. Example:
  663.             lprints("Hello, world");
  664.             lcrlf();
  665.             lprintc(FF);
  666.  
  667.  
  668. Name:       lprintc
  669. Purpose:    prints a character on the printer
  670. Prototype:  void lprintc(int ch)
  671. Inputs:     ch  - the character to print
  672. Return:     none
  673. Also see:   lcrlf lprints lprintsf
  674. Example:
  675.             lprints("Hello, world");
  676.             lcrlf();
  677.             lprintc(FF);
  678.  
  679.  
  680. Name:       lprints
  681. Purpose:    prints a string on the printer
  682. Prototype:  void lprints(char *str)
  683. Inputs:     str     - the address of the string to print
  684. Return:     none
  685. Also see:   lcrlf lprintc lprintsf
  686. Example:
  687.             lprints("Hello, world");
  688.             lcrlf();
  689.             lprintc(FF);
  690.  
  691.  
  692. Name:       lprintsf
  693. Purpose:    prints a string on the printer, formatting width
  694. Prototype:  void lprintsf(char *str,int width)
  695. Inputs:     str     - the address of the string to print
  696.             width   - width to print string, uses padding or truncating
  697. Return:     none
  698. Also see:   lcrlf lprintc lprints
  699. Example:
  700.             lprintsf("Hello, world",5);
  701.             lcrlf();
  702.             lprintc(FF);
  703.  
  704.  
  705. Name:       machid
  706. Purpose:    returns the value of the machine ROM ID byte
  707. Prototype:  int machid(void)
  708. Inputs:     none
  709. Return:     the value of the machine ROM ID byte
  710. Also see:   biosver
  711. Example:
  712.             if(machid()==IBMPCAT) printf("You have an IBM PC/AT\n");
  713.  
  714.  
  715. Name:       mathchip
  716. Purpose:    determines if a math coprocessor is installed
  717. Prototype:  int mathchip(int equip)
  718.  
  719.  
  720.                                       11
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727. Inputs:     equip   - the result from the biosequip() function
  728. Return:     a 1 if a math coprocessor is installed
  729. Also see:   gameport numflop numpar numser
  730. Example:
  731.             int i;
  732.             i=biosequip();
  733.             printf("Math coprocessor is %sinstalled\n",mathchip(i)?"":"not ");
  734.  
  735.  
  736. Name:       mode
  737. Purpose:    sets the video mode
  738. Prototype:  void mode(int mode_code)
  739. Inputs:     mode_code   - mode code number
  740. Return:     none
  741. Also see:   vidtype
  742. Example:
  743.             mode(4);
  744.             printf("We are now in CGA graphics mode\n");
  745.  
  746.  
  747. Name:       numflop
  748. Purpose:    determine the number of floppy disk drives installed
  749. Prototype:  int numflop(int equip)
  750. Inputs:     equip   - the result from the biosequip() function
  751. Return:     the number of floppy disk drives installed
  752. Also see:   gameport mathchip numpar numser
  753. Example:
  754.             int i;
  755.             i=biosequip();
  756.             printf("Number of floppy disk drives = %d\n",numflop(i));
  757.  
  758.  
  759. Name:       numoff
  760. Purpose:    toggle <NumLock> off
  761. Prototype:  void numoff(void)
  762. Inputs:     none
  763. Return:     none
  764. Also see:   capsoff capson kbstat numon
  765. Example:
  766.             numoff();
  767.  
  768.  
  769. Name:       numon
  770. Purpose:    toggle <NumLock> on
  771. Prototype:  void numon(void)
  772. Inputs:     none
  773. Return:     none
  774. Also see:   capsoff capson kbstat numoff
  775. Example:
  776.             numon();
  777.  
  778.  
  779. Name:       numpar
  780. Purpose:    determines the number of parallel ports
  781. Prototype:  int numpar(int equip)
  782. Inputs:     equip   - the result from the biosequip() function
  783. Return:     the number of parallel ports installed
  784.  
  785.  
  786.                                       12
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793. Also see:   gameport mathchip numflop numser
  794. Example:
  795.             int i;
  796.             i=biosequip();
  797.             printf("Number of parallel ports = %d\n",numpar(i));
  798.  
  799.  
  800. Name:       numser
  801. Purpose:    determines the number of serial ports installed
  802. Prototype:  int numser(int equip)
  803. Inputs:     equip   - the result from the biosequip() function
  804. Return:     the number of serial ports installed
  805. Also see:   gameport mathchip numflop numpar
  806. Example:
  807.             int i;
  808.             i=biosequip();
  809.             printf("Number of serial ports = %d\n",numser(i));
  810.  
  811.  
  812. Name:       printc
  813. Purpose:    prints a character to the screen at a specified location and
  814.             attribute
  815. Prototype:  void printc(int row,int col,int attr,int ch,int count)
  816. Inputs:     row     - row
  817.             col     - column
  818.             attr    - attribute of character
  819.             ch      - character to print
  820.             count   - number of times to print character
  821. Return:     none
  822. Also see:   attrib printcd prints printsd
  823. Example:
  824.             printc(18,60,LGREEN|BLINK,'Z',5);
  825.  
  826.  
  827. Name:       printcd
  828. Purpose:    prints a character directly to the screen at a specified
  829.             location and attribute (no BIOS calls)
  830. Prototype:  void printcd(int row,int col,int attr,int ch)
  831. Inputs:     row     - row
  832.             col     - column
  833.             attr    - attribute of character
  834.             ch      - character to print
  835. Return:     none
  836. Also see:   attrib printc prints printsd
  837. Example:
  838.             printcd(18,60,LGREEN|BLINK,'Z');
  839.  
  840.  
  841. Name:       prints
  842. Purpose:    displays a string on the screen at a specified location
  843.             and attribute
  844. Prototype:  void prints(int row,int col,int attr,char *str)
  845. Inputs:     row     - cursor row
  846.             col     - cursor column
  847.             attr    - character attribute
  848.             str     - address of string to display
  849. Return:     none
  850.  
  851.  
  852.                                       13
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859. Also see:   attrib printc printcd printsd
  860. Example:
  861.             prints(20,10,LRED|_LGREY,"Hello, world");
  862.  
  863.  
  864. Name:       printsd
  865. Purpose:    display a string at a specified location in a specified
  866.             attribute directly on the screen (no BIOS calls)
  867. Prototype:  void printsd(int row,int col,int attr,char *str)
  868. Inputs:     row     - cursor row
  869.             col     - cursor column
  870.             attr    - character attribute
  871.             str     - address of string to display
  872. Return:     none
  873. Also see:   attrib printc printcd prints
  874. Example:
  875.             printsd(20,10,LRED|_LGREY,"Hello, world");
  876.  
  877.  
  878. Name:       prompts
  879. Purpose:    prompts for a string and accepts keyboard input
  880. Prototype:  void prompts(char *prompt,char *str)
  881. Inputs:     prompt  - address of string containing prompt
  882.             str     - address of where to place input string
  883. Return:     none
  884. Example:
  885.             char name[30];
  886.             prompts("Enter your name:  ",name);
  887.  
  888.  
  889. Name:       readchat
  890. Purpose:    reads the character and attribute under the cursor
  891. Prototype:  int readchat(void)
  892. Inputs:     none
  893. Return:     integer containing character in low byte and attribute in high byte
  894. Also see:   gotoxy_ readcur revattr setattr
  895. Example:
  896.             int i;
  897.             prints(0,0,LGREEN|_BLUE,"Hello, world");
  898.             gotoxy_(0,7);
  899.             i=readchat();
  900.             gotoxy_(1,0);
  901.             printf("character is %c and attribute is %d\n",i,(i>>8));
  902.  
  903.  
  904. Name:       readcur
  905. Purpose:    reads the current cursor location
  906. Prototype:  void readcur(int *row,int *col)
  907. Inputs:     row     - address of location to receive cursor row
  908.             col     - address of location to receive cursor column
  909. Return:     none
  910. Also see:   gotoxy_ readchat
  911. Example:
  912.             int row,col;
  913.             readcur(&row,&col);
  914.             prints(0,0,LCYAN|BLINK,"Hello, world");
  915.             prints(row,col,LWHITE,"Hello,world");
  916.  
  917.  
  918.                                       14
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927. Name:       revattr
  928. Purpose:    reverses the attribute of the character under the current cursor
  929.             location
  930. Prototype:  void revattr(int count)
  931. Inputs:     count   - the number of characters to reverse attribute of
  932. Return:     none
  933. Also see:   readchat setattr
  934. Example:
  935.             prints(0,0,LCYAN|_BLUE,"Hello, world");
  936.             gotoxy_(0,0);
  937.             revattr(5);
  938.  
  939.  
  940. Name:       scrndump
  941. Purpose:    dumps the current CGA screen to the printer
  942. Prototype:  void scrndump(void)
  943. Inputs:     none
  944. Return:     none
  945. Also see:   lprintc lprints lprintsf
  946. Example:
  947.             printf("Turn printer on and press a key to continue....");
  948.             waitkey();
  949.             scrndump();
  950.  
  951.  
  952. Name:       setattr
  953. Purpose:    sets the attribute of the character under the current cursor
  954.             location
  955. Prototype:  void setattr(int attr,int count)
  956. Inputs:     attr    - attribute to set character
  957.             count   - the number of characters to set the attribute of
  958. Return:     none
  959. Also see:   readchat revattr
  960. Example:
  961.             prints(0,0,LCYAN|_BLUE,"Hello, world");
  962.             gotoxy_(0,0);
  963.             setattr(LRED|BLINK,5);
  964.  
  965.  
  966. Name:       setcursz
  967. Purpose:    sets the cursor size
  968. Prototype:  void setcursz(int sline,int eline)
  969. Inputs:     sline   - start line of cursor (32 for no cursor)
  970.             eline   - end line of cursor
  971. Return:     none
  972. Example:
  973.             setcursz(1,7);
  974.             printf("The cursor is now large\n");
  975.  
  976.  
  977. Name:       sound_
  978. Purpose:    sounds a tone of specified pitch and duration
  979. Prototype:  void sound_(unsigned pitch,unsigned duration)
  980. Inputs:     pitch       - pitch of tone (0-65535)
  981.             duration    - duration of tone (0-65535) ie. 18 = 1 second
  982.  
  983.  
  984.                                       15
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991. Return:     none
  992. Also see:   beep
  993. Example:
  994.             sound_(255,3);
  995.  
  996.  
  997. Name:       spc
  998. Purpose:    displays a specified number of spaces to the screen
  999. Prototype:  void spc(int num)
  1000. Inputs:     num     - number of spaces to display
  1001. Return:     none
  1002. Example:
  1003.             prints(15,50,7,"0123456789");
  1004.             gotoxy_(15,53);
  1005.             spc(3);
  1006.  
  1007.  
  1008. Name:       srestore
  1009. Purpose:    restores a previously saved CGA screen
  1010. Prototype:  void srestore(int *sbuf)
  1011. Inputs:     sbuf    - address of previously saved CGA screen buffer
  1012. Return:     none
  1013. Also see:   ssave wsave wrestore
  1014. Example:
  1015.             int *sbuf;
  1016.             sbuf=ssave();
  1017.             clrscrn();
  1018.             srestore(sbuf);
  1019.  
  1020.  
  1021. Name:       ssave
  1022. Purpose:    saves the current CGA screen
  1023. Prototype:  int *ssave(void)
  1024. Inputs:     none
  1025. Return:     address of newly created CGA screen buffer or 0 if allocation error
  1026. Also see:   srestore wsave wrestore
  1027. Example:
  1028.             int *sbuf;
  1029.             sbuf=ssave();
  1030.             clrscrn();
  1031.             srestore(sbuf);
  1032.  
  1033.  
  1034. Name:       strchg
  1035. Purpose:    finds all letters in a string matching one character and
  1036.             replaces them with another
  1037. Prototype:  void strchg(char *str,char oldch,char newch)
  1038. Inputs:     str     - address of string to search
  1039.             oldch   - character to search for
  1040.             newch   - character to replace with
  1041. Return:     none
  1042. Also see:   strichg
  1043. Example:
  1044.             char *str="Hello there";
  1045.             printf("Before:  %s\n",str);
  1046.             strchg(str,'h','*');
  1047.             printf("After:  %s\n",str);
  1048.  
  1049.  
  1050.                                       16
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059. Name:       strdel
  1060. Purpose:    deletes a substring from within a string
  1061. Prototype:  int strdel(char *substr,char *str)
  1062. Inputs:     substr  - address of substring to delete
  1063.             str     - address of string to delete from
  1064. Return:     a 0 if the substring was not found in the string
  1065. Also see:   stridel striinc strinc strmid
  1066. Example:
  1067.             char *str="Hello, XXXXXworld";
  1068.             strdel("XXXXX",str);
  1069.             printf("%s\n",str);
  1070.  
  1071.  
  1072. Name:       strichg
  1073. Purpose:    finds all letters in a string matching one character and
  1074.             replaces them with another, ignoring case of letters
  1075. Prototype:  void strichg(char *str,char oldch,char newch)
  1076. Inputs:     str     - address of string to search
  1077.             oldch   - character to search for
  1078.             newch   - character to replace with
  1079. Return:     none
  1080. Also see:   strchg
  1081. Example:
  1082.             char *str="Hello there";
  1083.             printf("Before:  %s\n",str);
  1084.             strichg(str,'h','*');
  1085.             printf("After:  %s\n",str);
  1086.  
  1087.  
  1088. Name:       stridel
  1089. Purpose:    deletes a substring from within a string, ignoring case of letters
  1090. Prototype:  int stridel(char *substr,char *str)
  1091. Inputs:     substr  - address of substring to delete
  1092.             str     - address of string to delete from
  1093. Return:     a 0 if the substring was not found in the string
  1094. Also see:   strdel striinc strinc strmid
  1095. Example:
  1096.             char *str="Hello, XXXXXworld";
  1097.             stridel("XXXXX",str);
  1098.             printf("%s\n",str);
  1099.  
  1100.  
  1101. Name:       striinc
  1102. Purpose:    determines if one string1 is included in string2, ignoring
  1103.             case of letters
  1104. Prototype:  char *striinc(char *str1,char *str2)
  1105. Inputs:     str1    - address of string1
  1106.             str2    - address of string2
  1107. Return:     the address where string1 is included in string2, or a 0 if
  1108.             string1 is not included in string2
  1109. Also see:   strinc
  1110. Example:
  1111.             char *str1="HeLlo WOrLd";
  1112.             char *str2="XXXXXXXHello, worldXXXXX";
  1113.             if(striinc(str1,str2)) printf("%s is included in %s\n",str1,str2);
  1114.  
  1115.  
  1116.                                       17
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125. Name:       strinc
  1126. Purpose:    determines if one string1 is included in string2
  1127. Prototype:  char *strinc(char *str1,char *str2)
  1128. Inputs:     str1    - address of string1
  1129.             str2    - address of string2
  1130. Return:     the address where string1 is included in string2, or a 0 if
  1131.             string1 is not included in string2
  1132. Also see:   striinc strmid
  1133. Example:
  1134.             char *str1="Hello world";
  1135.             char *str2="XXXXXXXHello, worldXXXXX";
  1136.             if(strinc(str1,str2)) printf("%s is included in %s\n",str1,str2);
  1137.  
  1138.  
  1139. Name:       striocc
  1140. Purpose:    returns the number of occurrences of a character in a string
  1141.             ignoring the case of letters
  1142. Prototype:  int striocc(char *str,int ch)
  1143. Inputs:     str     - address of the string to search
  1144.             ch      - the character to look for
  1145. Return:     the number of occurrences of the character in the string
  1146. Also see:   strocc
  1147. Example:
  1148.             char ch='L';
  1149.             char *str="Hello, world";
  1150.             printf("%c occurs in %s %d times\n",ch,str,striocc(str,ch));
  1151.  
  1152.  
  1153. Name:       strleft
  1154. Purpose:    takes a specified portion of a string from the left and creates
  1155.             a new string
  1156. Prototype:  char *strleft(char *str,int num_chars)
  1157. Inputs:     str         - address of input string
  1158.             num_chars   - number of characters to copy
  1159. Return:     address of the newly created string or a 0 if a memory allocation
  1160.             error occurred
  1161. Also see:   strdel stridel striinc strinc strmid strright
  1162. Example:
  1163.             char *left;
  1164.             char *str="Hello, worldXXXX";
  1165.             left=strmid(str,12);
  1166.             printf("%s\n",left);
  1167.             free(left);             /*  free memory when done with string  */
  1168.  
  1169.  
  1170. Name:       strmid
  1171. Purpose:    takes a section from input string starting at given position
  1172.             and taking the given amount of characters creating a new string
  1173. Prototype:  char *strmid(char *str,int st_pos,int num_chars)
  1174. Inputs:     str         - address of input string
  1175.             st_pos      - position in input string to start copying characters
  1176.                           (starting at position 0)
  1177.             num_chars   - number of characters to copy
  1178. Return:     address of the newly created string or a 0 if a memory allocation
  1179.             error occurred
  1180.  
  1181.  
  1182.                                       18
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189. Also see:   strdel stridel striinc strinc strleft strright
  1190. Example:
  1191.             char *middle;
  1192.             char *str="XXXXXHello, worldXXXX";
  1193.             middle=strmid(str,5,12);
  1194.             printf("%s\n",middle);
  1195.             free(middle);             /*  free memory when done with string  */
  1196.  
  1197.  
  1198. Name:       strocc
  1199. Purpose:    returns the number of occurrences of a character in a string
  1200. Prototype:  int strocc(char *str,int ch)
  1201. Inputs:     str     - address of the string to search
  1202.             ch      - the character to look for
  1203. Return:     the number of occurrences of the character in the string
  1204. Also see:   striocc
  1205. Example:
  1206.             char ch='l';
  1207.             char *str="Hello, world";
  1208.             printf("%c occurs in %s %d times\n",ch,str,strocc(str,ch));
  1209.  
  1210.  
  1211. Name:       strright
  1212. Purpose:    takes a specifed portion from the right side of a string creating
  1213.             a new string
  1214. Prototype:  char *strright(char *str,int num_chars)
  1215. Inputs:     str         - address of input string
  1216.             num_chars   - number of characters to copy
  1217. Return:     address of the newly created string or a 0 if a memory allocation
  1218.             error occurred
  1219. Also see:   strdel stridel striinc strinc strleft strmid
  1220. Example:
  1221.             char *right;
  1222.             char *str="XXXXXHello, world";
  1223.             right=strright(str,12);
  1224.             printf("%s\n",right);
  1225.             free(right);             /*  free memory when done with string  */
  1226.  
  1227.  
  1228. Name:       strsetsz
  1229. Purpose:    adjusts the length of a string by truncation or padding with
  1230.             spaces
  1231. Prototype:  char *strsetsz(char **str,int newsize)
  1232. Inputs:     str     - address of pointer to the string
  1233.             newsize - the new length of the string
  1234. Return:     address of the new string or a 0 if a memory allocation error
  1235.             occurred
  1236. Example:
  1237.             char *str="Hello, world";
  1238.             strsetsz(&str,25);
  1239.             printf("%s.\n",str);
  1240.             strsetsz(&str,5);
  1241.             printf("%s.\n",str);
  1242.  
  1243.  
  1244. Name:       tabstop
  1245. Purpose:    calculates a tab stop from given column and tab width
  1246.  
  1247.  
  1248.                                       19
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255. Prototype:  int tabstop(int col,int tabwidth)
  1256. Inputs:     col         - column
  1257.             tabwidth    - tab width
  1258. Return:     the next tab stop
  1259. Example:
  1260.             printf("tabstop after column 5 is %d\n",tabstop(5,8);
  1261.  
  1262.  
  1263. Name:       timer
  1264. Purpose:    returns the value of the BIOS timer
  1265. Prototype:  unsigned long timer(void)
  1266. Inputs:     none
  1267. Return:     current value of the BIOS timer
  1268. Also see:   delay_
  1269. Example:
  1270.             printf("%lu\n",timer());
  1271.             delay_(36);
  1272.             printf("%ul\n",timer());
  1273.  
  1274.  
  1275. Name:       vidtype
  1276. Purpose:    determines the display adapter type
  1277. Prototype:  int vidtype(void)
  1278. Inputs:     none
  1279. Return:     a 2 for EGA, 1 for CGA, or 0 for MDA
  1280. Also see:   mode
  1281. Example:
  1282.             int i;
  1283.             i=vidtype();
  1284.             if(i) printf("A color adapter is installed\n");
  1285.  
  1286.  
  1287. Name:       wactiv
  1288. Purpose:    activates a currently open window
  1289. Prototype:  int wactiv(int whandle)
  1290. Inputs:     whandle     - the window handle returned from the wopen() function
  1291. Return:     a zero if no error, see TCXL.H for return codes
  1292. Also see:   wclose wopen
  1293. Example:
  1294.             int w1,w2;
  1295.             w1=wopen(0,0,20,20,0,LMAGENTA|_RED);
  1296.             waitkey();
  1297.             w2=wopen(10,10,15,50,0,LGREEN|_BLUE);
  1298.             waitkey();
  1299.             wactiv(w1);
  1300.             waitkey();
  1301.             wclose();
  1302.             wclose();
  1303.  
  1304.  
  1305. Name:       waitkey
  1306. Purpose:    halts execution until a key is pressed
  1307. Prototype:  int waitkey(void)
  1308. Inputs:     none
  1309. Return:     the key pressed
  1310. Also see:   clearkeys
  1311. Example:
  1312.  
  1313.  
  1314.                                       20
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.             printf("Press any key to continue...");
  1322.             waitkey();
  1323.  
  1324.  
  1325. Name:       wclear
  1326. Purpose:    clears the currently active window
  1327. Prototype:  void wclear(void)
  1328. Inputs:     none
  1329. Return:     none
  1330. Also see:   wclreol
  1331. Example:
  1332.             wopen(10,10,20,20,0,WHITE|_GREEN);
  1333.             wprints(11,11,7,"Hello");
  1334.             wclear();
  1335.             waitkey();
  1336.             wclose();
  1337.  
  1338.  
  1339. Name:       wclose
  1340. Purpose:    closes the currently active window
  1341. Prototype:  void wclose(void)
  1342. Inputs:     none
  1343. Return:     none
  1344. Also see:   wmove wopen
  1345. Example:
  1346.             wopen(10,10,20,20,1,LCYAN|_BLUE);
  1347.             waitkey();
  1348.             wclose();
  1349.  
  1350.  
  1351. Name:       wclreol
  1352. Purpose:    clears to the end of the active window's line
  1353. Prototype:  void wclreol(void)
  1354. Inputs:     none
  1355. Return:     none
  1356. Also see:   wclear
  1357. Example:
  1358.             wopen(10,10,20,40,0,LMAGENTA|_RED);
  1359.             wputs("Hello, world");
  1360.             wgotoxy(0,5);
  1361.             wclreol();
  1362.             waitkey();
  1363.             wclose();
  1364.  
  1365.  
  1366. Name:       wgetc
  1367. Purpose:    gets a character from the keyboard within the active window, echos
  1368.             character pressed to the screen in the attribute set by the
  1369.             wtextattr() function
  1370. Prototype:  int wgetc(void)
  1371. Inputs:     none
  1372. Return:     the ASCII value of the key pressed
  1373. Also see:   wgetchf wgets wgetsf wtextattr
  1374. Example:
  1375.             wopen(0,0,5,30,0,LCYAN|_BLUE);
  1376.             wputs("Press a key:  ");
  1377.             wputs("\nYou pressed %c",wgetc());
  1378.  
  1379.  
  1380.                                       21
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.             waitkey();
  1388.             wclose();
  1389.  
  1390.  
  1391. Name:       wgetchf
  1392. Purpose:    gets a character from the keyboard within the active window, allows
  1393.             only characters listed in the string of valid characters and the
  1394.             Escape key, echos character pressed to the screen in the attribute
  1395.             set by the wtextattr() function
  1396. Prototype:  int wgetchf(char *valid)
  1397. Inputs:     valid   - string containing valid characters
  1398. Return:     the ASCII value of the key pressed
  1399. Also see:   wgetc wgets wgetsf wtextattr
  1400. Example:
  1401.             wopen(0,0,5,30,0,LCYAN|_BLUE);
  1402.             wputs("Are you sure? ");
  1403.             wputs("\nYou pressed %c",wgetchf("YyNn"));
  1404.             waitkey();
  1405.             wclose();
  1406.  
  1407.  
  1408. Name:       wgets
  1409. Purpose:    gets a string from the keyboard within active window, echos the
  1410.             characters to the screen in the attribute set by the wtextattr()
  1411.             function
  1412. Prototype:  void wgets(char *str)
  1413. Inputs:     str     - the address of the string to receive the input characters
  1414. Return:     none
  1415. Also see:   wgetc wgetchf wgetsf wtextattr
  1416. Example:
  1417.             char fname[20];
  1418.             wopen(0,0,5,60,0,LCYAN|_BLUE);
  1419.             wputs("Enter your first name:  ");
  1420.             wgets(fname);
  1421.             wputs("\nYour first name is:  %s",fname);
  1422.             waitkey();
  1423.             wclose();
  1424.  
  1425.  
  1426. Name:       wgetsf
  1427. Purpose:    gets a string from the keyboard within active window, limits the
  1428.             number of characters input to specified length, checks for the
  1429.             Escape key being pressed, echos the characters to the screen in
  1430.             the attribute set by the wtextattr() function
  1431. Prototype:  int wgetsf(char *str,int maxlen)
  1432. Inputs:     str     - address of the string to receive the input characters
  1433.             maxlen  - the maximum length of the input string
  1434. Return:     a non-zero value if the Escape key was pressed, see TCXL.H for
  1435.             the return codes
  1436. Also see:   wgetc wgetchf wgets wtextattr
  1437. Example:
  1438.             char fname[20];
  1439.             wopen(0,0,5,60,0,LCYAN|_BLUE);
  1440.             wputs("Enter your first name:  ");
  1441.             wgetsf(fname,5);
  1442.             wputs("\nYour first name is:  %s",fname);
  1443.             waitkey();
  1444.  
  1445.  
  1446.                                       22
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.             wclose();
  1454.  
  1455.  
  1456. Name:       wgotoxy
  1457. Purpose:    plots cursor coordinates within the currently active window
  1458. Prototype:  int wgotoxy(int wrow,int wcol)
  1459. Inputs:     wrow    - window row
  1460.             wcol    - window column
  1461. Return:     a non-zero value if an attempt was made to plot outside of window
  1462. Also see:   wprintc wprints
  1463. Example:
  1464.             wopen(0,0,10,10,0,YELLOW|_BLUE);
  1465.             wgotoxy(1,1);
  1466.             wputs("Hello");
  1467.  
  1468.  
  1469. Name:       whide
  1470. Purpose:    hides a window
  1471. Prototype:  int *whide(int **wbuf)
  1472. Inputs:     wbuf    - address of the pointer to the window buffer to hide
  1473. Return:     the address of the hidden window's buffer or a 0 if a memory
  1474.             allocation error occurred
  1475. Also see:   wclose wopen wrestore wsave wunhide
  1476. Example:
  1477.             wopen(0,0,15,50,0,LCYAN|_BLUE);
  1478.             waitkey();
  1479.             whide(&_wrecord[_wcurrent].wbuf);
  1480.             waitkey();
  1481.             wunhide(&_wrecord[_wcurrent].wbuf);
  1482.             waitkey();
  1483.             wclose();
  1484.  
  1485.  
  1486. Name:       wmove
  1487. Purpose:    moves the currently active window to a new location
  1488. Prototype:  int wmove(int nsrow,int nscol)
  1489. Inputs:     nsrow   - new starting row of window
  1490.             nscol   - new starting column of window
  1491. Return:     a zero if no error occurred, see TCXL.H for return codes
  1492. Also see:   wclose wopen wsize
  1493. Example:
  1494.             wopen(10,10,20,20,2,LCYAN|_BLUE);
  1495.             waitkey();
  1496.             wmove(0,0);
  1497.             waitkey();
  1498.             wclose();
  1499.  
  1500.  
  1501. Name:       wopen
  1502. Purpose:    opens a CGA screen window and makes it active, only 10 windows can
  1503.             be open at a time, registered users may recompile this function to
  1504.             allow more windows
  1505. Prototype:  int wopen(int srow,int scol,int erow,int ecol,int btype,int attr)
  1506. Inputs:     srow    - starting row, upper left corner
  1507.             scol    - starting column, upper left corner
  1508.             erow    - ending row, lower right corner
  1509.             ecol    - ending column, lower right corner
  1510.  
  1511.  
  1512.                                       23
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.             btype   - box type (0-3)
  1520.             attr    - attribute of window
  1521. Return:     window handle or a zero if an error occurred
  1522. Also see:   wclose wactiv
  1523. Example:
  1524.             wopen(10,10,20,20,0,LCYAN|_BLUE);
  1525.             waitkey();
  1526.             wclose();
  1527.  
  1528.  
  1529. Name:       wprintc
  1530. Purpose:    prints a character in the currently active window, does not adjust
  1531.             cursor
  1532. Prototype:  int wprintc(int row,int col,int attr,int ch)
  1533. Inputs:     row     - cursor row (of the window)
  1534.             col     - cursor column (of the window)
  1535.             attr    - character attribute
  1536.             ch      - character
  1537. Return:     non-zero if an attempt was made to plot outside of the window
  1538. Also see:   wprints wputc wputs wputsf
  1539. Example:
  1540.             wopen(10,10,20,20,0,WHITE|_GREEN);
  1541.             wprintc(11,11,7,"T");
  1542.             waitkey();
  1543.             wclose();
  1544.  
  1545.  
  1546. Name:       wprints
  1547. Purpose:    prints a string in the currently active window, does not adjust
  1548.             cursor
  1549. Prototype:  int wprints(int row,int col,int attr,char *str)
  1550. Inputs:     row     - cursor row (of the window)
  1551.             col     - cursor column (of the window)
  1552.             attr    - attribute
  1553.             str     - address of string
  1554. Return:     non-zero if an attempt was made to plot outside of the window
  1555. Also see:   wprintc wputc wputs wputsf
  1556. Example:
  1557.             wopen(10,10,20,20,0,WHITE|_GREEN);
  1558.             wprints(11,11,7,"Hello");
  1559.             waitkey();
  1560.             wclose();
  1561.  
  1562.  
  1563. Name:       wputc
  1564. Purpose:    prints a character in currently active window at current cursor
  1565.             location, uses attribute set by the wtextattr() function
  1566. Prototype:  void wputc(int ch)
  1567. Inputs:     ch  - the character to be printed
  1568. Return:     a non-zero value if current cursor location is not within window
  1569. Also see:   wgotoxy wprintc wprints wputs wputsf wtextattr
  1570. Example:
  1571.             wopen(10,10,20,20,0,WHITE|_GREEN);
  1572.             wgotoxy(5,5);
  1573.             wtextattr(LMAGENTA|BLINK);
  1574.             wputc('X');
  1575.             waitkey();
  1576.  
  1577.  
  1578.                                       24
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.             wclose();
  1586.  
  1587.  
  1588. Name:       wputs
  1589. Purpose:    prints a string in currently active window at the current cursor
  1590.             location, uses attribute set by the wtextattr() function
  1591. Prototype:  void wputs(char *str)
  1592. Inputs:     str     - the address of the string to print
  1593. Return:     a non-zero value if current cursor location is not within window
  1594. Also see:   wgotoxy wprintc wprints wputc wputsf wtextattr
  1595. Example:
  1596.             wopen(10,10,20,20,0,WHITE|_GREEN);
  1597.             wgotoxy(1,1);
  1598.             wtextattr(LMAGENTA|BLINK);
  1599.             wputs("Hello, world");
  1600.             waitkey();
  1601.             wclose();
  1602.  
  1603.  
  1604. Name:       wputsf
  1605. Purpose:    prints a string in the active window, formatting width of output,
  1606.             uses attribute set by the wtextattr() function
  1607. Prototype:  void wputsf(char *str,int width)
  1608. Inputs:     str     - address of the string to print
  1609.             width   - width to display output string with
  1610. Return:     none
  1611. Also see:   wgotoxy wprintc wprints wputc wputs wtextattr
  1612. Example:
  1613.             wopen(10,10,20,20,0,WHITE|_GREEN);
  1614.             wgotoxy(1,1);
  1615.             wtextattr(LMAGENTA|BLINK);
  1616.             wputsf("Hello, world",5);
  1617.             waitkey();
  1618.             wclose();
  1619.  
  1620.  
  1621. Name:       wrestore
  1622. Purpose:    restores a previously saved window of CGA screen memory
  1623. Prototype:  void wrestore(int *wbuf)
  1624. Inputs:     wbuf    - address of previously saved window
  1625. Return:     none
  1626. Also see:   srestore ssave whide wsave wunhide
  1627. Example:
  1628.             int *wbuf;
  1629.             wbuf=wsave(7,7,18,60);
  1630.             clrscrn();
  1631.             wrestore(wbuf);
  1632.  
  1633.  
  1634. Name:       wsave
  1635. Purpose:    saves a window of CGA screen memory
  1636. Prototype:  int *wsave(int srow,int scol,int erow,int ecol)
  1637. Inputs:     srow    - starting row, upper left corner
  1638.             scol    - starting column, upper left corner
  1639.             erow    - ending row, lower right corner
  1640.             ecol    - ending column, lower right corner
  1641. Return:     address of newly created window buffer or 0 if allocation error
  1642.  
  1643.  
  1644.                                       25
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651. Also see:   srestore ssave whide wrestore wunhide
  1652. Example:
  1653.             int *wbuf;
  1654.             wbuf=wsave(7,7,18,60);
  1655.             clrscrn();
  1656.             wrestore(wbuf);
  1657.  
  1658.  
  1659. Name:       wscroll
  1660. Purpose:    scrolls text within the active window, up or down
  1661. Prototype:  void wscroll(int count,int direction)
  1662. Inputs:     wbuf        - the address of the window buffer of the window
  1663.             count       - number of lines to scroll
  1664.             direction   - a 0 to scroll down or non-zero to scroll up
  1665. Return:     none
  1666. Also see:   wclose wopen wputc wputs
  1667. Example:
  1668.             wopen(10,10,20,20,0,WHITE|_GREEN);
  1669.             wprints(11,11,7,"Hello");
  1670.             waitkey();
  1671.             wscroll(2,DOWN);
  1672.             waitkey();
  1673.             wclose();
  1674.  
  1675.  
  1676. Name:       wsize
  1677. Purpose:    adjusts the size of the active window
  1678. Prototype:  int wsize(int nerow,int necol)
  1679. Inputs:     nerow   - new end row of sized window
  1680.             necol   - new end column of sized window
  1681. Return:     a zero if no error occurred, see TCXL.H for return codes
  1682. Also see:   wmove
  1683. Example:
  1684.             wopen(10,10,20,20,0,WHITE|_GREEN);
  1685.             waitkey();
  1686.             wsize(23,40);
  1687.             waitkey();
  1688.             wsize(15,15);
  1689.             waitkey();
  1690.             wclose();
  1691.  
  1692.  
  1693. Name:       wtextattr
  1694. Purpose:    sets the default text attribute used by some windowing functions
  1695. Prototype:  void wtextattr(int attr)
  1696. Inputs:     attr    - the new text attribute
  1697. Return:     none
  1698. Also see:   wgetc wgetchf wgets wgetsf wprintc wprints wputc wputs wputsf
  1699. Example:
  1700.             wopen(10,10,20,20,0,WHITE|_GREEN);
  1701.             wgotoxy(1,1);
  1702.             wtextattr(LMAGENTA|BLINK);
  1703.             wputs("Hello, world");
  1704.             waitkey();
  1705.             wclose();
  1706.  
  1707.  
  1708.  
  1709.  
  1710.                                       26
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717. Name:       wunhide
  1718. Purpose:    unhides a previously hidden window
  1719. Prototype:  int *wunhide(int **wbuf)
  1720. Inputs:     wbuf    - address of the pointer to the window buffer to unhide
  1721. Return:     the address of the unhidden window's buffer or a 0 if a memory
  1722.             allocation error occurred
  1723. Also see:   whide wrestore wsave
  1724. Example:
  1725.             wopen(0,0,15,50,0,LCYAN|_BLUE);
  1726.             waitkey();
  1727.             whide(&_wrecord[_wcurrent].wbuf);
  1728.             waitkey();
  1729.             wunhide(&_wrecord[_wcurrent].wbuf);
  1730.             waitkey();
  1731.             wclose();
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.                                       27
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.                               Global Variables
  1785.                               ----------------
  1786.  
  1787. Name:       _wcurrent
  1788. Purpose:    contains the array subscript of the window that is currently active
  1789. Type:       int
  1790.  
  1791.  
  1792. Name:       _whandle
  1793. Purpose:    contains the last handle number given to a window
  1794. Type:       int
  1795.  
  1796. Name:       _wrecord
  1797. Purpose:    an array of window records which contains window handles and window
  1798.             buffer pointers
  1799. Type:       struct _wrecord  (see TCXL.H for definition)
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.                                       28
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.